package com.wzxy.wzinfo.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.transaction.annotation.Transactional;


/**
 * jpa Service基本接口
 * 以下方法可从jpa的Repository接口及其子接口找到
 * @author pan
 *
 * @param <T>对象类型
 * @param <ID>ID类型
 */
public interface IMyJpaService<T, ID extends Serializable> {

	public T save(T t);
	
	T findOne(ID id);

	boolean exists(ID id);
	
	long count();
	
	void delete(ID id);
	
	void delete(T entity);
	
	List<T> findAll();
	
	List<T> findAll(Sort sort);

	List<T> findAll(Iterable<ID> ids);
	
	void deleteInBatch(Iterable<T> entities);

	void deleteAllInBatch();

	T getOne(ID id);
	
	Page<T> findAll(Pageable pageable);
	
	
	/*-----------动态拼接参数查询方法---------------*/
	T findOne(Specification<T> spec);

	
	List<T> findAll(Specification<T> spec);

	
	Page<T> findAll(Specification<T> spec, Pageable pageable);

	
	List<T> findAll(Specification<T> spec, Sort sort);

	long count(Specification<T> spec);
	
	/*------------------自定义接口------------------*/
	@Transactional
	public T update(T t,ID id);

}
